<template>
  <div class="app-container doctor">
    <el-form
      ref="queryForm"
      :model="queryParams"
      :inline="true"
      label-width="68px"
    >
      <el-form-item label="姓名" prop="name">
        <el-input
          v-model="queryParams.name"
          placeholder="请输入姓名"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!--      <el-form-item label="年龄" prop="age">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.age"-->
      <!--          placeholder="请输入年龄"-->
      <!--          clearable-->
      <!--          size="small"-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <el-form-item label="性别" prop="sex">
        <el-select
          v-model="queryParams.sex"
          placeholder="请选择性别"
          clearable
          size="small"
        >
          <el-option
            v-for="dict in sexOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="手机号" prop="phone">
        <el-input
          v-model="queryParams.phone"
          placeholder="请输入手机号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="科室" prop="departId">
        <!--       <el-input
          v-model="queryParams.depart"
          placeholder="请输入科室"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        /> -->
        <el-select v-model="queryParams.departId" placeholder="请选择科室">
          <el-option
            v-for="dict in departList"
            :key="dict.id"
            :label="dict.depart"
            :value="dict.id"
          />
        </el-select>
      </el-form-item>

      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          v-hasPermi="['biz:doctor:add']"
          type="primary"
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          >新增</el-button
        >
      </el-col>

      <el-col :span="1.5">
        <el-button
          v-hasPermi="['biz:doctor:remove']"
          type="danger"
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          >删除</el-button
        >
      </el-col>
      <!--      <el-col :span="1.5">-->
      <!--        <el-button-->
      <!--          v-hasPermi="['biz:doctor:export']"-->
      <!--          type="warning"-->
      <!--          icon="el-icon-download"-->
      <!--          size="mini"-->
      <!--          @click="handleExport"-->
      <!--        >导出</el-button>-->
      <!--      </el-col>-->
    </el-row>

    <el-table
      v-loading="loading"
      :data="doctorList"
      @selection-change="handleSelectionChange"
      height="67vh"
    >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="医生ID" align="center" prop="doctorID" />
      <el-table-column label="姓名" align="center" prop="name" width="110" />
      <el-table-column label="年龄" align="center" prop="age" />
      <el-table-column
        label="性别"
        align="center"
        prop="sex"
        :formatter="sexFormat"
      />
      <el-table-column label="手机号" align="center" prop="phone" width="110" />
      <el-table-column label="科室" align="center" prop="depart" />
      <el-table-column label="职称" align="center" prop="title" width="100" />
      <el-table-column label="专长" align="center" prop="special" />
      <el-table-column
        label="所属医院"
        align="center"
        prop="hospital"
        width="110"
      />
      <!-- <el-table-column label="备注" align="center" prop="remark" width="150" /> -->
      <el-table-column
        label="会诊专家"
        align="center"
        prop="isMaster"
        :formatter="isMasterFormat"
      />
      <el-table-column
        label="值班状态"
        align="center"
        prop="onDutyStatus"
        :formatter="onDutyStatusFormat"
      />
      <!-- <el-table-column label="账户状态" align="center" prop="accountStatus" :formatter="accountStatusFormat" /> -->
      <el-table-column
        label="用户状态"
        align="center"
        prop="status"
        :formatter="statusFormat"
      />
      <!-- <el-table-column label="班组编号" align="center" prop="classid" /> -->
      <el-table-column
        label="排班状态"
        align="center"
        prop="classStatus"
        :formatter="classStatusFormat"
      />
      <!--      <el-table-column label="上次登陆时间" align="center" prop="lastLogin" width="180">-->
      <!--        <template slot-scope="scope">-->
      <!--          <span>{{ parseTime(scope.row.lastLogin, '{y}-{m}-{d}') }}</span>-->
      <!--        </template>-->
      <!--      </el-table-column>-->

      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
        fixed="right"
      >
        <template slot-scope="scope">
          <el-button
            v-hasPermi="['biz:doctor:edit']"
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            >查看</el-button
          >
          <el-button
            v-hasPermi="['biz:doctor:remove']"
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            >删除</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-lightning"
            style="color: #ff0000"
            @click="handelLight(scope.row)"
            v-show="!(scope.row.accountStatus == 1 && scope.row.status == 1)"
          >
            停用
          </el-button>

          <el-button
            size="mini"
            type="text"
            icon="el-icon-lightning"
            @click="handleModifyPassword(scope.row)"
          >
            重置密码
          </el-button>

        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <el-dialog
      title="重置密码"
      :visible.sync="passopen"
      width="800px"
      :before-close="handleClosePass"
      append-to-body
    >
      <el-form ref="passform" :model="passform" :rules="passrules" label-width="100px">
        <el-form-item label="新密码" prop="password">
          <el-input
            v-model="passform.password"
            autocomplete="new-password"
            type="password"
            placeholder="请输入密码"
          />
        </el-form-item>
        <el-form-item label="确认新密码" prop="confirm_password" label-width="100px">
          <el-input
            v-model="passform.confirm_password"
            autocomplete="new-password"
            type="password"
            placeholder="请输入确认密码"
          />
        </el-form-item>
        <el-form-item>
            <el-button @click="submitPassForm()">提交</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>


    <!-- 添加或修改医生管理对话框 -->
    <el-dialog
      :title="title"
      :visible.sync="open"
      :width="interlayerWidth"
      :before-close="handleDialogClose"
      append-to-body
    >
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-row class="dialog-title">
          <el-col :span="24">
            <el-button :type="elButtonType" @click="submitForm(modifyCont)">{{
              modifyCont
            }}</el-button>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="9">
            <el-form-item class="logo" label="头像" prop="image">
              <img
                class="logoImg"
                v-if="!isShow"
                v-for="(item, index) in form.fieldfileList"
                :src="item.url"
                :key="index"
                alt=""
              />
              <el-upload
                :limit="1"
                ref="image"
                :file-list="form.fieldfileList"
                :action="imageAction"
                :before-upload="field105BeforeUpload"
                :headers="headers"
                :on-success="quillImgSuccess"
                :on-remove="removeFormImage"
                list-type="picture-card"
                accept="image/*"
                v-if="isShow"
              >
                <i class="el-icon-plus" />
                <div slot="tip" class="el-upload__tip">
                  只能上传不超过 5MB 的image/*文件
                </div>
                <!-- <el-button size="small" type="primary" icon="el-icon-upload">点击上传</el-button> -->
              </el-upload>
            </el-form-item>
          </el-col>
          <el-col :span="1.5">
            <el-form-item label="姓名" prop="name">
              <el-input
                v-if="isShow"
                v-model="form.name"
                placeholder="请输入姓名"
              />
              <div class="dialog-text" v-if="!isShow">{{ form.name }}</div>
            </el-form-item>
            <el-form-item label="性别">
              <el-select
                v-model="form.sex"
                placeholder="请选择性别"
                v-if="isShow"
              >
                <el-option
                  v-for="dict in sexOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                />
              </el-select>

              <div class="dialog-text" v-if="!isShow">{{ gender }}</div>
            </el-form-item>
            <el-form-item label="年龄" prop="age">
              <el-input
                v-model="form.age"
                placeholder="请输入年龄"
                v-if="isShow"
              />
              <div class="dialog-text" v-if="!isShow">{{ form.age }}</div>
            </el-form-item>
            <el-form-item label="手机号" prop="phone">
              <el-input
                v-model="form.phone"
                placeholder="请输入手机号"
                v-if="isShow"
              />
              <div class="dialog-text" v-if="!isShow">{{ form.phone }}</div>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="1.5">
            <el-form-item label="职称" prop="title">
              <el-input
                v-model="form.title"
                placeholder="请输入职称"
                v-if="isShow"
              />
              <div class="dialog-text" v-if="!isShow">{{ form.title }}</div>
            </el-form-item>
            <el-form-item label="科室" prop="departId">
              <!-- <el-input v-model="form.depart" placeholder="请输入科室" /> -->
              <el-select
                v-model="form.departId"
                placeholder="请选择科室"
                v-if="isShow"
              >
                <el-option
                  v-for="depart in departList"
                  :key="depart.id"
                  :label="depart.depart"
                  :value="depart.id"
                />
              </el-select>
              <div class="dialog-text" v-if="!isShow">{{ form.depart }}</div>
            </el-form-item>
            <el-form-item label="专长" prop="special">
              <el-input
                v-model="form.special"
                placeholder="请输入专长"
                v-if="isShow"
              />
              <div class="dialog-text" v-if="!isShow">{{ form.special }}</div>
            </el-form-item>
          </el-col>
          <el-col :span="1.5">
            <el-form-item label="会诊专家">
              <el-select
                v-model="form.isMaster"
                placeholder="请选择会诊专家"
                v-if="isShow"
              >
                <el-option
                  v-for="dict in isMasterOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                />
              </el-select>
              <div class="dialog-text" v-if="!isShow">{{ isExpert }}</div>
            </el-form-item>

            <el-form-item label="值班状态">
              <el-radio-group v-model="form.onDutyStatus" v-if="isShow">
                <el-radio
                  v-for="dict in onDutyStatusOptions"
                  :key="dict.dictValue"
                  :label="dict.dictValue"
                  >{{ dict.dictLabel }}</el-radio
                >
              </el-radio-group>
              <div class="dialog-text" v-if="!isShow">{{ isWork }}</div>
            </el-form-item>

            <el-form-item label="用户状态">
              <el-select
                v-model="form.status"
                placeholder="请选择用户状态"
                v-if="isShow"
              >
                <el-option
                  v-for="dict in statusOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                />
              </el-select>
              <div class="dialog-text" v-if="!isShow">{{ userState }}</div>
            </el-form-item>
          </el-col>
        </el-row>

        <!--        <el-form-item label="排班状态">
          <el-select v-model="form.classStatus" placeholder="请选择排班状态">
            <el-option
              v-for="dict in classStatusOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            />
          </el-select>
        </el-form-item> -->
      </el-form>

      <div v-show="tableShow">
        <div>
          <h3>历史调度记录</h3>
        </div>
        <el-table v-loading="loading" :data="dispathList">
          <el-table-column
            label="调度流水号"
            align="center"
            prop="flow"
            :show-overflow-tooltip="true"
          />
          <el-table-column
            label="出车时间"
            align="center"
            prop="leaveHospTime"
            width="180"
          >
            <template slot-scope="scope">
              <span>{{
                parseTime(scope.row.leaveHospTime, "{y}-{m}-{d} {h}:{i}:{s}")
              }}</span>
            </template>
          </el-table-column>
          <el-table-column label="司机" align="center" prop="driverName" />
          <el-table-column label="护士" align="center" prop="nurseName" />
          <el-table-column
            label="接车地点"
            align="center"
            prop="patientLocal"
            width="110"
          />
          <el-table-column label="收治医院" align="center" prop="hospital" />
          <el-table-column
            label="患者病历"
            align="center"
            prop="caseFlow"
            width="100"
            :show-overflow-tooltip="true"
          />
        </el-table>
        <pagination
          v-show="totals > 0"
          :total="totals"
          :page.sync="queryParam.pageNum"
          :limit.sync="queryParam.pageSize"
          @pagination="getCustomer"
        />
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listDoctor,
  getDoctor,
  delDoctor,
  addDoctor,
  updateDoctor,
  exportDoctor,
  getDepartList,
  lightDoctor,
  customer,
  modifyPass
} from "@/api/biz/doctor";
import { getToken } from "@/utils/auth";
export default {
  name: "Doctor",
  data() {
    return {
      dispathList: [],
      tableShow: false,
      passopen: false,
      interlayerWidth: "1200px",
      // 遮罩层
      loading: true,
      imageAction: process.env.VUE_APP_BASE_API + "/common/upload",
      // 上传时要的 token
      headers: {
        Authorization: "Bearer " + getToken()
      },
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 总条数
      total: 0,
      totals: 0,
      // 医生管理表格数据
      doctorList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 会诊专家字典
      isMasterOptions: [],
      // 值班状态字典
      onDutyStatusOptions: [],
      // 账户状态字典
      accountStatusOptions: [],
      // 性别字典
      sexOptions: [],
      // 用户状态字典
      statusOptions: [],
      // 排班状态字典
      classStatusOptions: [],
      // 科室列表
      departList: [],
      // 科室选中id
      departCurrentId: "",
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        name: undefined,
        phone: undefined,
        depart: undefined,
        isMaster: undefined,
        title: undefined,
        onDutyStatus: undefined,
        special: undefined,
        hospital: undefined,
        lastLogin: undefined,
        accountStatus: undefined,
        age: undefined,
        sex: undefined,
        status: undefined,
        classid: undefined,
        classStatus: undefined,
        ids: undefined
      },
      // 医生详情查询
      queryParam: {
        pageNum: 1,
        pageSize: 10,
        doctorID: undefined
      },
      // 表单参数
      form: {},
      passform:{},
      // 表单校验
      rules: {
        name: [
          {
            required: true,
            message: "姓名不能为空",
            trigger: "blur"
          },
          {
            pattern: /^[\u4E00-\u9FA5\uf900-\ufa2d·s]{2,20}$/,
            message: "姓名格式错误",
            trigger: "blur"
          }
        ],
        phone: [
          {
            required: true,
            message: "手机号不能为空",
            trigger: "blur"
          },
          {
            pattern: /^1(3|4|5|7|8|9)\d{9}$/,
            message: "手机号格式错误",
            trigger: "blur"
          }
        ],
        depart: [
          {
            required: true,
            message: "科室不能为空",
            trigger: "blur"
          }
        ],
        isMaster: [
          {
            required: true,
            message: "会诊专家不能为空",
            trigger: "blur"
          }
        ],
        title: [
          {
            required: true,
            message: "职称不能为空",
            trigger: "blur"
          }
        ],
        onDutyStatus: [
          {
            required: true,
            message: "值班状态不能为空",
            trigger: "blur"
          }
        ],
        special: [
          {
            required: true,
            message: "专长不能为空",
            trigger: "blur"
          }
        ],
        hospital: [
          {
            required: true,
            message: "所属医院不能为空",
            trigger: "blur"
          }
        ],
        age: [
          {
            required: true,
            message: "年龄不能为空",
            trigger: "blur"
          },
          {
            pattern: /^(?:[1-9][0-9]?|1[01][0-9]|120)$/,
            message: "超过年龄范围1~120",
            trigger: "blur"
          }
        ],
        sex: [
          {
            required: true,
            message: "性别不能为空",
            trigger: "blur"
          }
        ],
        departId: [
          {
            required: true,
            message: "科室不能为空",
            trigger: "blur"
          }
        ],
        image: [
          {
            required: true,
            message: "头像不能为空",
            trigger: "blur"
          }
        ]
      },
      passrules: {
        password: [
          {
            required: true,
            message: "不能为空",
            trigger: "blur",
          }
        ],
        confirm_password: [
          {
            required: true,
            message: "不能为空",
            trigger: "blur"
          }
        ],
      },
      logoImg: "",
      // 医生详情 查看or切换
      isShow: true,
      // 性别
      gender: "",
      //是否专家
      isExpert: "",
      // 值班状态
      isWork: "",
      // 用户状态
      userState: "",
      // 修改文本
      modifyCont: "编辑资料",
      //按钮样式
      elButtonType: "",
      istrue: ""
    };
  },
  created() {
    this.getList();
    this.getDicts("is_consultant").then(response => {
      this.isMasterOptions = response.data;
    });
    this.getDicts("doctor_duty_status").then(response => {
      this.onDutyStatusOptions = response.data;
    });
    this.getDicts("common_status").then(response => {
      this.accountStatusOptions = response.data;
    });
    this.getDicts("sys_user_sex").then(response => {
      this.sexOptions = response.data;
    });
    this.getDicts("common_status").then(response => {
      this.statusOptions = response.data;
    });
    this.getDicts("class_status").then(response => {
      this.classStatusOptions = response.data;
    });
    this.getDepartLists();
  },
  methods: {
    /** 查询医生管理列表 */
    getList() {
      this.loading = true;
      listDoctor(this.queryParams).then(response => {
        this.doctorList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 获取科室列表
    getDepartLists() {
      getDepartList().then(response => {
        this.departList = response.rows;
      });
    },
    // 图片校验
    field105BeforeUpload(file) {
      const isRightSize = file.size / 1024 / 1024 < 5;
      if (!isRightSize) {
        this.$message.error("文件大小超过 5MB");
      }
      const isAccept = new RegExp("image/*").test(file.type);
      if (!isAccept) {
        this.$message.error("应该选择image/*类型的文件");
      }
      return isRightSize && isAccept;
    },
    // 会诊专家字典翻译
    isMasterFormat(row, column) {
      return this.selectDictLabel(this.isMasterOptions, row.isMaster);
    },
    // 值班状态字典翻译
    onDutyStatusFormat(row, column) {
      return this.selectDictLabel(this.onDutyStatusOptions, row.onDutyStatus);
    },
    // 账户状态字典翻译
    accountStatusFormat(row, column) {
      return this.selectDictLabel(this.accountStatusOptions, row.accountStatus);
    },
    // 性别字典翻译
    sexFormat(row, column) {
      // console.log(this.selectDictLabel(this.sexOptions, row.sex));

      return this.selectDictLabel(this.sexOptions, row.sex);
    },
    // 用户状态字典翻译
    statusFormat(row, column) {
      return this.selectDictLabel(this.statusOptions, row.status);
    },
    // 排班状态字典翻译
    classStatusFormat(row, column) {
      return this.selectDictLabel(this.classStatusOptions, row.classStatus);
    },
    // 图片上传成功处理
    quillImgSuccess(res, file) {
      // res为图片服务器返回的数据

      // 如果上传成功
      if (res.code === 200) {
        // 获取光标所在位置xx
        this.form.image = res.fileName;
        // this.fieldfileList.push(res.url)
      } else {
        this.$message.error("图片插入失败");
      }
    },
    // 删除图片操作
    removeFormImage(row) {
      this.form.image = null;
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        doctorid: undefined,
        name: undefined,
        phone: undefined,
        depart: undefined,
        remark: undefined,
        account: undefined,
        password: undefined,
        isMaster: "1",
        title: undefined,
        onDutyStatus: "0",
        special: undefined,
        hospital: undefined,
        lastLogin: undefined,
        loginIp: undefined,
        role: undefined,
        author: undefined,
        accountStatus: "0",
        age: undefined,
        sex: "0",
        status: "0",
        classid: undefined,
        classStatus: undefined,
        uid: undefined,
        fieldfileList: [],
        image: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.doctorID);
      if (this.ids.length != 0) {
        this.queryParams.ids = this.ids.join(",");
      } else {
        this.queryParams.ids = undefined;
      }
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "新增医生";
      this.interlayerWidth = "780px";
      this.modifyCont = "保存";
      this.elButtonType = "primary";
      this.isShow = true;
      this.tableShow = false;
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      console.log(row);
      //显示文本
      this.isShow = false;
      // 性别
      this.gender = this.selectDictLabel(this.sexOptions, row.sex);
      // 专家
      this.isExpert = this.selectDictLabel(this.isMasterOptions, row.isMaster);
      //  值班状态
      this.isWork = this.selectDictLabel(
        this.onDutyStatusOptions,
        row.onDutyStatus
      );
      // 用户状态
      this.userState = this.selectDictLabel(this.statusOptions, row.status);

      // this.sexOptions.forEach(element => {
      //   console.log(element);
      // });
      // this.gender = row.sex;

      // this.logoImg = require(row.image);
      // this.logoImg = row.image;
      this.reset();
      this.interlayerWidth = "780px";
      this.tableShow = true;
      const doctorid = row.doctorID || this.ids;
      getDoctor(doctorid).then(response => {
        this.form = response.data;
        this.form.sex = String(response.data.sex);
        this.form.classStatus = String(response.data.classStatus);
        this.form.status = String(response.data.status);
        this.form.isMaster = String(response.data.isMaster);
        this.form.accountStatus = String(response.data.accountStatus);
        this.form.onDutyStatus = String(response.data.onDutyStatus);
        const images = [];
        if (response.data.image !== null) {
          images.push({
            name: "123",
            url: process.env.VUE_APP_BASE_API + response.data.image
          });
        }
        this.form.fieldfileList = images;
        console.log(images);
        this.queryParam.doctorID = doctorid;
        customer(this.queryParam).then(response => {
          this.totals = response.total;
          this.dispathList = response.rows;
        });
        console.log(this.form.fieldfileLists);
        this.open = true;
        this.title = "医生详情";
      });
    },
    getCustomer() {
      this.loading = true;
      customer(this.queryParam).then(response => {
        this.totals = response.total;
        this.dispathList = response.rows;
        this.loading = false;
      });
    },
    /** 提交按钮 */
    submitForm: function(e) {
      if (e == "编辑资料") {
        this.modifyCont = "保存";
        this.elButtonType = "primary";
        // this.reset();
        this.isShow = true;
        return true;
      }
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.doctorID !== undefined) {
            updateDoctor(this.form).then(response => {
              if (response.code === 200) {
                this.getList();
                this.modify(e);
              } else {
                this.msgError(response.msg);
              }
            });
          } else {
            addDoctor(this.form).then(response => {
              if (response.code === 200) {
                this.getList();
                this.modify(e);
              } else {
                this.msgError(response.msg);
              }
            });
          }
        }
      });
    },

    //修改密码
    submitPassForm() {
      this.$refs["passform"].validate(valid => {
        if (valid) {
          if (this.passform.password != this.passform.confirm_password) {
              this.msgError("两次密码不一致");
              return false;
          }
          var phoneTest = /^[a-z0-9]{6,18}$/;
          if (!phoneTest.test(this.passform.password)) {
            this.msgError("密码格式要求6-18位数字或字母");
            return false;
          }
            modifyPass(this.passform).then(response => {
                if (response.code == 200) {
                  this.msgSuccess("OK");
                  this.handleClosePass();
                } else {
                  this.msgError(response.msg);
                }
            })
        }
      });
    },
    handleModifyPassword(row) {
      this.passopen = true;
      this.passform.doctorID = row.doctorID;
    },
    handleClosePass() {
      this.passopen = false ;
      this.passform.doctorID = undefined;
      this.passform.password = undefined;
      this.passform.confirm_password = undefined;
    },










    /** 删除按钮操作 */
    handleDelete(row) {
      const doctorids = row.doctorID || this.ids;
      this.$confirm(
        '是否确认删除医生管理编号为"' + doctorids + '"的数据项?',
        "警告",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }
      )
        .then(function() {
          return delDoctor(doctorids);
        })
        .then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        })
        .catch(function() {});
    },
    /**  冻结操作 */
    handelLight(row) {
      const doctorids = row.doctorID || this.ids;
      console.log(doctorids);
      this.$confirm(
        '是否确认停用医生管理编号为"' + doctorids + '"的数据项?',
        "警告",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }
      )
        .then(function() {
          return lightDoctor(doctorids);
        })
        .then(() => {
          this.getList();
          this.msgSuccess("停用成功");
        })
        .catch(function() {});
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm("是否确认导出所有医生管理数据项?", "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(function() {
          return exportDoctor(queryParams);
        })
        .then(response => {
          this.download(response.msg);
        })
        .catch(function() {});
    },
    //关闭弹窗
    handleDialogClose() {
      // this.isShow = true;
      this.open = false;
      this.modifyCont = "编辑资料";
      this.elButtonType = "";
    },
    // 医生详情-输入框状态
    modify(e) {
      if (e == "编辑资料") {
        this.modifyCont = "保存";
        this.elButtonType = "primary";
        // this.reset();
        this.open = false;
      } else {
        // 新增
        this.elButtonType = "";
        setTimeout(() => {
          this.modifyCont = "编辑资料";
          this.reset();
          this.open = false;
        }, 300);
      }
    }
  }
};
</script>
<style lang="scss" scoped>
.logoImg {
  width: 146px !important;
  height: 146px !important;
  border-radius: 6px;
}

.dialog-title {
  width: 100%;

  > div {
    line-height: 16px;
    font-size: 16px;
    text-align: right;
    cursor: pointer;
    color: #333;
  }
}

.dialog-text {
  width: 200px;
}
/* 分页 */
.pagination-container {
  height: 80px;
  margin-top: 0px;
  padding: 23px 20px !important;
}
/* 分页  end */
</style>
